package cn.imokay.springboot.yml.controller;

import cn.imokay.springboot.yml.configmodel.AnotherConfigModel;
import cn.imokay.springboot.yml.configmodel.ConfigValidateModel;
import cn.imokay.springboot.yml.configmodel.ValuePropertiesModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 孟震
 */
@RestController
//注入的配置类通过ConstructorBinding时,需要开启以下注解,同时配置类不需要Compment等注解
//@EnableConfigurationProperties(ConfigModel.class)
public class HelloSpringbootYmlController2 {
    @Autowired
    private AnotherConfigModel anotherModel;

    @RequestMapping("hello2")
    public String hello2(){
        System.out.println(anotherModel.toString());

        return anotherModel.toString();
    }

    @Autowired
    private ConfigValidateModel vm;

    @RequestMapping("hello3")
    public String hello3(){
        System.out.println(vm.toString());

        return vm.toString();
    }

    @Autowired
    private ValuePropertiesModel vpm;

    @RequestMapping("hello4")
    public String hello4(){
        System.out.println(vpm.toString());

        return vpm.toString();
    }
}
